﻿using AutoMapper;
using MachineVision.Domain;
using MachineVision.Service.Dto;
using Microsoft.EntityFrameworkCore;

namespace MachineVision.Service
{
    public class MenuService : IMenuService
    {
        private readonly VisionDbContext context;
        private readonly IMapper mapper;

        public MenuService(VisionDbContext context, IMapper mapper)
        {
            this.mapper = mapper;
            this.context = context;
        }

        public List<MenuData> GetDatas()
        {
            List<Menu> data = context.Menus.Where(s=>s.IsMain&&!s.Inactive).Include(s=>s.Pages).OrderBy(s => s.Id).ToList();
            data.ForEach(s => s.Pages = s.Pages.Where(s => !s.Inactive));
            return mapper.Map<List<MenuData>>(data);
        }

        public bool AddData(MenuData res)
        {
            throw new NotImplementedException();
        }

        public MenuData GetData(int Id)
        {
            throw new NotImplementedException();
        }

        public bool ModifyData(int Id, MenuData value)
        {
            throw new NotImplementedException();
        }
    }
}